var express = require('express');
var path = require('path');
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');

var webpackConfig = require('./webpack.config');

var app = express();

var compiler = webpack(webpackConfig);
var port = process.env.port || 8080;

app.use(express.static(path.join(__dirname)));

app.use(webpackDevMiddleware(compiler, {
  publicPath: '/dist/',
  stats: {
    colors: true
  }
}));

app.use(webpackHotMiddleware(compiler));

app.listen(port, function () {
  console.log('project run in ' + port + ' port')
});